﻿using Bling.DSL;
using Bling.Core;
using Bling.WPF;
using Bling.Util;


using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System;


namespace NewBlingExample {
  using Bling.Core;
  using Bling.Angles;
  using Bling.Matrices;
  class NewExample : Canvas {
    public NewExample() {
      var Canvas = this.Bl();

      var M0 = new MatrixBl<D2, D3>(+1, +0, -2,
                                    +0, +3, -1);
      var M1 = new MatrixBl<D3, D2>(+0, +3,
                                    -2, -1,
                                    +0, +4);

      var M2 = M0.Product<D2>(M1);

      Console.WriteLine(("M2=".Bl() + M2.ToStringBl(100d)).CurrentValue);



      var q = this.Property(QuaternionBl.Identity);


      var rA = new QuaternionBl(new Double3Bl(1, 1, 1), .33.PI());
      var rB = new QuaternionBl(new Double3Bl(-1, -.5, -1), .7.PI());
      q.Bind =  (rA * rB);


      var S = Matrix4Bl.MakeScale(3d);
      var T = (Matrix4Bl.MakeTranslate(10d));
      var TS = T * S;
      var ST = S * T;

      var M = (Matrix4Bl.MakeScale(3d) * q.Matrix);
      Console.WriteLine(("S=".Bl() + S.ToStringBl(100d)).CurrentValue);
      Console.WriteLine(("T=".Bl() + T.ToStringBl(100d)).CurrentValue);
      Console.WriteLine(("TS=".Bl() + TS.ToStringBl(100d)).CurrentValue);
      Console.WriteLine(("ST=".Bl() + ST.ToStringBl(100d)).CurrentValue);

      var qST = q.Matrix * ST;

      var p = new Double3Bl(10, -10, 20);
      var pp = qST.Transform(p);
      var ppp = qST.Inverse.Transform(pp);
      Console.WriteLine(("S = ".Bl() + qST.ToStringBl(100d)).CurrentValue);
      Console.WriteLine(("SM= ".Bl() + qST.Inverse.ToStringBl(100d)).CurrentValue);
      Console.WriteLine((pp.ToStringBl(100d) + " " + ppp.ToStringBl(100d)).CurrentValue);



      //Console.WriteLine(("Q=".Bl() + q.Matrix.ToStringBl(100d)).CurrentValue);
      //Console.WriteLine(("S=".Bl() + S.ToStringBl(100d) + " * ... = " + M.ToStringBl(100d)).CurrentValue);
      //Console.WriteLine(("M * P=".Bl() + P.ToStringBl(100d) + " = " + (M * P).ToStringBl(100d)).CurrentValue);




    }
  }
}